import {observable,action} from 'mobx';
import * as taskAdd from '../../apis/task/taskAdd'

export default class TaskAddStore {
    @observable cubeLayoutParame = {};//装载布局请求入参
    @observable Card = {};
    //initCallBack = {};
    isloading = true;
    isMandatoryArry = [];
    constructor() {

    }
    //初始化
    @action
    initForm = params => {
        taskAdd.getTaskSetupInit(params).then(action((result) => {
            if(result.status==1 && result.isopen === true){
                this.isloading = false;
                this.cubeLayoutParame = {...result.data};
                if(params.doback){
                    params.doback();
                }
            }
        }));
    }
    // setInitCallBack  = params => {
    //     this.initCallBack = params.doback;
    // }
    @action
    getCardStorefun = (store)=>{
        this.isloading = true;
        this.Card = store;
        // const{init} = this.Card;
        // const{initParame} = this.cubeLayoutParame;
        // init({...initParame},this.initCallBack());
        // if(this.Card.isInit){
        //     this.spinning = false;
        // }
    }
    @action
    saveTask = params =>{
        if (Object.keys(this.cubeLayoutParame).length > 0) {//建模布局保存方法
            const { ecmeDoSubmit } = this.Card.Actions;
            ecmeDoSubmit().then((data) => {
                if(params.doback){
                   params.doback(data.JSONStr.mainTable.TM_TaskInfo,1,data.JSONStr.extendDatas);
                }
            })
        }else{
            if(params.doback){
                params.doback("",2);
            }
        }
    }
}